package com.example.sprintboot.service;

import com.example.sprintboot.entity.Gourmet;
import com.example.sprintboot.mapper.GourmetMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GourmetService {
    @Resource
    private GourmetMapper gourmetMapper;

    public List<Gourmet> selectAll() {
        return gourmetMapper.selectAll(); // 调用 EmployeeMapper 的方法
    }


    public Gourmet selectById(Integer id) {
        return  gourmetMapper.selectById(id);
    }

    public void add(Gourmet gourmet) {
        gourmetMapper.add(gourmet);
    }

    public void update(Gourmet gourmet) {
        gourmetMapper.update(gourmet);
    }

    public void delete(Integer id) {
        gourmetMapper.delete(id);
    }

    public PageInfo<Gourmet> page(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Gourmet> list =  gourmetMapper.selectAll();
        return PageInfo.of(list);
    }

    public PageInfo<Gourmet> query(String title, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Gourmet> list = gourmetMapper.query(title);
        return PageInfo.of(list);
    }
}
